package com.chixing.day15_map;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class OutputStreamDemo {

    public static void main(String[] args) {
        //写数据到 d:test1/hello.txt

        //1.创建字节写入流
        OutputStream os = null;
        try {
            os=new FileOutputStream("d://test1/hello.txt");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        //2.写数据
        String content = "sssssssssssssssssssssssssssssssssssssssss"+"aaaaaaaaaaaaaaaaa";
        try {
            os.write(content.getBytes());
        } catch (IOException e) {
           e.printStackTrace();
        }finally { //3.关闭流（释放内存，节约资源）
            if (os !=null){
                try {
                    os.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
